package pl.cvplus.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_annex", schema = "public", catalog = "")
@Entity
public class CpAnnex {
    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String annexName;

    @javax.persistence.Column(name = "annex_name", nullable = true, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getAnnexName() {
        return annexName;
    }

    public void setAnnexName(String annexName) {
        this.annexName = annexName;
    }

    private byte[] file;

    @javax.persistence.Column(name = "file", nullable = true, insertable = true, updatable = true, length = 2147483647, precision = 0)
    @Basic
    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

    private Integer cvFk;

    @javax.persistence.Column(name = "cv_fk", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getCvFk() {
        return cvFk;
    }

    public void setCvFk(Integer cvFk) {
        this.cvFk = cvFk;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpAnnex cpAnnex = (CpAnnex) o;

        if (annexName != null ? !annexName.equals(cpAnnex.annexName) : cpAnnex.annexName != null) return false;
        if (cvFk != null ? !cvFk.equals(cpAnnex.cvFk) : cpAnnex.cvFk != null) return false;
        if (!Arrays.equals(file, cpAnnex.file)) return false;
        if (id != null ? !id.equals(cpAnnex.id) : cpAnnex.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (annexName != null ? annexName.hashCode() : 0);
        result = 31 * result + (file != null ? Arrays.hashCode(file) : 0);
        result = 31 * result + (cvFk != null ? cvFk.hashCode() : 0);
        return result;
    }

    private CpCv cpCvByCvFk;

    @ManyToOne
    public
    @javax.persistence.JoinColumn(name = "cv_fk", referencedColumnName = "id")
    CpCv getCpCvByCvFk() {
        return cpCvByCvFk;
    }

    public void setCpCvByCvFk(CpCv cpCvByCvFk) {
        this.cpCvByCvFk = cpCvByCvFk;
    }
}
